package com.whenjun.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ifootbook.util.EmptyUtil;
import com.whenjun.dto.door.IscDoorDTO;
import com.whenjun.dto.door.IscDoorReq;
import com.whenjun.entity.IscDoor;
import com.whenjun.entity.IscPerson;
import com.whenjun.entity.KqConfig;
import com.whenjun.mapper.KqConfigMapper;
import com.whenjun.service.IKqConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author whenjun
 * @since 2024-02-20
 */
@Service
public class KqConfigServiceImpl extends ServiceImpl<KqConfigMapper, KqConfig> implements IKqConfigService {

    @Transactional
    public KqConfig KqConfig() {
        KqConfig kqConfig = this.getById("1");
        return kqConfig;
    }

    @Transactional
    public void KqConfigSet(KqConfig kqConfig) {
        LambdaUpdateWrapper<KqConfig> wrapper = new LambdaUpdateWrapper();
        wrapper.set(!EmptyUtil.isEmpty(kqConfig.getFloorRestTime()), KqConfig::getFloorRestTime, kqConfig.getFloorRestTime());
        wrapper.set(!EmptyUtil.isEmpty(kqConfig.getEightSumTime()), KqConfig::getEightSumTime, kqConfig.getEightSumTime());
        wrapper.set(!EmptyUtil.isEmpty(kqConfig.getSingleRestTime()), KqConfig::getSingleRestTime, kqConfig.getSingleRestTime());
        wrapper.set(!EmptyUtil.isEmpty(kqConfig.getWcTime()), KqConfig::getWcTime, kqConfig.getWcTime());
        wrapper.set(!EmptyUtil.isEmpty(kqConfig.getElasticTime1()), KqConfig::getElasticTime1, kqConfig.getElasticTime1());
        wrapper.set(!EmptyUtil.isEmpty(kqConfig.getElasticTime2()), KqConfig::getElasticTime2, kqConfig.getElasticTime2());
        wrapper.set(!EmptyUtil.isEmpty(kqConfig.getEightRestTime()), KqConfig::getEightRestTime, kqConfig.getEightRestTime());
        wrapper.set(!EmptyUtil.isEmpty(kqConfig.getTwelveRestTime()), KqConfig::getTwelveRestTime, kqConfig.getTwelveRestTime());
        wrapper.eq(KqConfig::getId, "1");
        this.update(wrapper);
    }


}
